From: Alessandro Bono Date: Wed, 1 May 2024 18:00:49 +0000 (+0200) Subject: gdm/util: Simplify code X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~226^2^2~81 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=5877de6c3bd5de0f20a16aa896e8ad5d7e1cc0f9;p=gnome-shell.git gdm/util: Simplify code This avoids iterating and checking if a service is foreground multiple times. Part-of: --- diff --git a/js/gdm/util.js b/js/gdm/util.js index 303be0d62..b5a544c8d 100644 --- a/js/gdm/util.js +++ b/js/gdm/util.js @@ -892,10 +892,10 @@ export class ShellUserVerifier extends Signals.EventEmitter { // If the login failed with the preauthenticated oVirt credentials // then discard the credentials and revert to default authentication // mechanism. - let foregroundService = Object.keys(this._credentialManagers).find(service => - this.serviceIsForeground(service)); - if (foregroundService) { - this._credentialManagers[foregroundService].token = null; + const isCredentialManager = !!this._credentialManagers[serviceName]; + const isForeground = this.serviceIsForeground(serviceName); + if (isCredentialManager && isForeground) { + this._credentialManagers[serviceName].token = null; this._preemptingService = null; this._verificationFailed(serviceName, false); return; @@ -909,7 +909,7 @@ export class ShellUserVerifier extends Signals.EventEmitter { // if the password service fails, then cancel everything. // But if, e.g., fingerprint fails, still give // password authentication a chance to succeed - if (this.serviceIsForeground(serviceName)) + if (isForeground) this._failCounter++; this._verificationFailed(serviceName, true);